package com.zh.app.dao.impl;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate4.HibernateTemplate;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;

import com.zh.app.dao.LogDao;
import com.zh.app.model.Log;

//@Component("logDao")
public class LogDaoImpl extends HibernateDaoSupport implements LogDao {

//	private SessionFactory sessionFactory;
//	private HibernateTemplate hibernateTemplate;

//	public SessionFactory getSessionFactory() {
//		return sessionFactory;
//	}
//
//	@Resource(name="sessionFactory")
//	public void setSessionFactory(SessionFactory sessionFactory) {
//		this.sessionFactory = sessionFactory;
//	}

//	public HibernateTemplate getHibernateTemplate() {
//		return hibernateTemplate;
//	}
//
//	@Resource(name="hibernateTemplate")
//	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
//		this.hibernateTemplate = hibernateTemplate;
//	}

	@Override
	public void save(Log log) {
		// TODO Auto-generated method stub
//		Session session = sessionFactory.getCurrentSession();
//		Session session = hibernateTemplate.getSessionFactory().getCurrentSession();
//		session.beginTransaction();
//		session.save(log);
//		throw new RuntimeException("error!");
//		session.getTransaction().commit();
//		System.out.println("a user saved log");
		this.getHibernateTemplate().save(log);
//		this.save(log);
	}

}
